<template>
  <a-modal :open="open" width="600px" title="皮试结果" centered :footer="null" @cancel="onCancel">
    <div class="px-4 pt-2 pb-4">
      <div class="flex items-center mb-2">
        <div class="text-base font-semibold truncate mr-2" :title="resultInfo?.mc">{{ resultInfo?.mc || '药品名称' }}</div>
        <div v-if="resultInfo.gg" class="text-gray-400 mr-2 text-xs truncate" :title="resultInfo?.gg">{{ resultInfo?.gg }}</div>
        <div v-if="resultInfo.cj" class="text-gray-400 mr-2 text-xs max-w-[64px] truncate" :title="resultInfo?.cj">{{ resultInfo?.cj }}</div>
      </div>
      <LabelValue class="mt-2" label-align="right" :width="180" tooltip label="皮试结果" :value="formatResult(resultInfo.skinTestResult)" />
      <LabelValue class="mt-2" label-align="right" :width="460" tooltip label="结果观察" :value="resultInfo.resultDescribe" />
      <div class="flex items-center mt-2">
        <LabelValue label-align="right" :width="260" tooltip label="开始时间" :value="resultInfo.skinTestStartTime" />
        <LabelValue label-align="right" :width="260" tooltip label="结束时间" :value="resultInfo.skinTestEndTime" />
      </div>
    </div>
  </a-modal>
</template>
<script setup>
import LabelValue from '@/components/LabelValue'

const props = defineProps({
  open: Boolean,
  rowData: {
    type: Object,
    default: () => ({})
  }
})
const resultInfo = ref({})

const emit = defineEmits(['update:open'])

const onCancel = () => {
  emit('update:open', false)
}
const formatResult = (val) => {
  // 皮试结果 0:阴性 1：弱阳性|2：阳性|3：强阳性
  if (val === 0) {
    return '阴性'
  } else if (val === 1) {
    return '弱阳性'
  } else if (val === 2) {
    return '阳性'
  } else if (val === 3) {
    return '强阳性'
  }
}
watch(
  () => props.open,
  (val) => {
    if (val && props.rowData.id) {
      resultInfo.value = { ...props.rowData }
    }
  }
)
</script>
